package com.cortex.pineapple.adapters;

import java.util.ArrayList;
import java.util.List;

import com.cortex.pineapple.R;
import com.cortext.pineapple.link.Link;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;


public abstract class LinkAdapter<T extends Link> extends BaseAdapter {

	protected Context context;
	protected List<T> links;

	public LinkAdapter(Context context) {
		this.context = context;
	}
	public LinkAdapter(Context context, List<T> links) {
		this.context = context;
		this.links = links;
	}

	@Override
	public int getCount() {
		return links.size();
	}

	@Override
	public Object getItem(int position) {
		return links.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	public List<T> getLinks(){
		return links;
	}
	public void addLinks(List<T> links) {
		this.links.addAll(links);
		this.notifyDataSetChanged();

	}
	public void clear() {
		links.clear();
	}
	abstract protected void buildItemView(T link ,ViewGroup linkView);

}
